#pragma once
#include "wbemcli.h"

class CWMIEventSink :
  public IWbemObjectSink
{
  friend class CWMIHandler;
public:
  virtual ~CWMIEventSink(void);
  virtual ULONG STDMETHODCALLTYPE AddRef();
  virtual ULONG STDMETHODCALLTYPE Release(); 

  virtual HRESULT 
      STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppv);

  bool isRegistered(void)
  {
    return m_bRegistered;
  }

protected:
  CWMIEventSink(void);

private:
  ULONG registerSelf(LPCTSTR lpcszQuery, IWbemServices *pWbemSvc);
  ULONG unregisterSelf(void);

private:
  long m_lRef;
  IUnsecuredApartment *m_pUnsecApp;
  IWbemObjectSink *m_pStubSink;
  bool m_bRegistered;
  IWbemServices *m_pWbemSvc;
};
